<template>
    <h2>修改页面</h2>
    <table>
        <tr>
            <td>
                投资名称
            </td>
            <td>
                <input type="text" v-model="I_Name" id="I_Name">
            </td>
        </tr>
        <tr>
            <td>
                投资总额度
            </td>
            <td>
                <input type="text" v-model="I_Budget" id="I_Budget">
            </td>
        </tr>
        <tr>
            <td>

            </td>
            <td>
                <input type="button" value="修改" @click="Upa">
            </td>
        </tr>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { onMounted } from 'vue';
import axios from 'axios';


const route = useRoute();
const I_Name = ref('');
const I_Budget = ref('');
const I_Id = route.params.I_Id;
//反填
onMounted(() => {
    axios.get('http://localhost:46407/api/Demo/Fans', {
        params: {
            I_Id: I_Id
        }
    })
        .then(res => {
            I_Name.value = res.data.I_Name;
            I_Budget.value = res.data.I_Budget;

        })
})
const Upa = () => {
    axios.post('http://localhost:46407/api/Demo/Upd', {
        I_Name: I_Name.value,
        I_Budget: I_Budget.value,
        I_Id: I_Id

    })
        .then(res => {
            if (res.data > 0) {
                alert("修改成功");
                location.href = '/InsertShow'
                return;
            }
            else {
                alert("修改失败");
                return;
            }
        })
}



</script>